package com.ytf.test.fifth;

/**
 * @author: YTF
 * @date: 2024/9/18 16:50
 * @version: 1.0
 * @description:
 */
public class Leaf {
    int i = 0;

    Leaf increment() {
        i++;
        return this;
    }

    void print() {
        System.out.println("i = " + i);
    }

    public static void main(String[] args) {
        Leaf leaf = new Leaf();
        leaf.increment().increment().increment().print();
        /**
         * Output:
         * i= 3
         * this 返回了当前对象的引用
         */
    }
}
